package com.mirei.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author direct模式绑定关系与监听
 */
@Slf4j
@Component
public class DirectListener {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "boot.direct.red"),
            exchange = @Exchange(name = "boot.direct", type = ExchangeTypes.DIRECT),
            key = {"red"}))
    public void listen1(String msg) {
        log.info("消费者收到[boot.direct.red]队列的消息,内容:{}", msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "boot.direct.blue"),
            exchange = @Exchange(name = "boot.direct", type = ExchangeTypes.DIRECT),
            key = {"blue"}))
    public void listen2(String msg) {
        log.info("消费者收到[boot.direct.blue]队列的消息,内容:{}", msg);
    }
}
